import apis from "../../http/apis/apis"

export default {
    //避免命名冲突
    namespaced: true,
    state: {
        tableData1: [
        ],
        currentPage1: 1,
        pageSize1: 5,
        total1: 0,
        pages1: 0,
    },
    mutations: {
        audittenants(state, data) {
            state.tableData1 = data.tableData,
                state.total1 = data.chaxunye,
                state.pages1 = data.chapages
        },
        //改变每页显示条数
        changePageSize(state, pageSize) {
            state.pageSize1 = pageSize
        },
        //改变当前页
        changecurrentPage(state, currentPage) {
            state.currentPage1 = currentPage
        },
    },
    actions: {
        //审核车位渲染列表
        async auditTenants(context, input) {
            console.log();
            const data = await apis.tenants.auditTenants({
                searchType: input.input1,
                searchValue: input.input2,
                currentPage: context.state.currentPage1,
                pageSize: context.state.pageSize1
            });
            if (data.status) {
                console.log(data.data);
                context.commit('audittenants', data.data.data)
            }
        },
        //改变状态
        async getState(context, a) {
            if (a.state == 1) {
                a.state = 2
            } else if (a.state == 2) {
                a.state = 1
            }
            const { data } = await apis.tenants.getState({
                _id: a._id,
                state: a.state
            });
            return data
        }
    },
}